package com.mind.server;

import java.io.IOException;

import org.apache.log4j.Logger;

import com.mind.core.log.ServerStatusLog;
import com.mind.core.server.GameServerRuntime;


public class StartGameServer {
	private static final Logger logger = Logger.getLogger(StartGameServer.class);
	public static void main(String[] args) throws IOException {
		logger.info("Starting Game Server");
//		ServerStatusUtil.systemInfo();
		// 初始化所有的Services服务
		logger.info("Init Services begin");
		GameServerRuntime.infoJvmStatus();
		try {
			ServerStatusLog.getDefaultLog().logStarting();
			ServerManager.initServices("localhost","8001","8002");
			ServerManager.startServices();
			ServerStatusLog.getDefaultLog().logRunning();
		} catch (Exception e) {
			// 服务初始化异常,停止启动服务,退出JVM
			logger.error("Init Services fail", e);
			System.err.println("Init Services fail,exit");
			System.out.flush();
			System.err.flush();
			ServerStatusLog.getDefaultLog().logStartFail();
			System.exit(1);
			return;
		}
		logger.info("Init Services end");
		logger.info("Game Server started");
//		ServerStatusUtil.systemInfo();
		GameServerRuntime.infoJvmStatus();
		logger.warn("游戏服务器启动完毕！");
	}

}
